package cn.huapu.power.energy.util.python;

import cn.huapu.power.energy.util.AesEncryptUtils;
import cn.huapu.power.energy.util.Configurationn;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.annotation.Configuration;

//
@Configuration
public class RunPython {

	private static Log log = LogFactory.getLog(RunPython.class);
	private static String pyPath = "";

	static {
		try {
			pyPath = AesEncryptUtils.decrypt((String) Configurationn.getConfigsetting().getProperty("pyPath"));
		} catch (Exception e) {
			log.error("init",e);
		}
	}
	/**
	 * run py
	 * @param pkid
	 */
	public static void runPeapy(String pkid) {
		try {
			log.info("runPeapy begin pkid="+pkid);
			run_OnlineDataDeal_py(pkid);
            run_OnlineOptimize_py(pkid);
            run_OnlineFeescore_py(pkid);
            run_OnlineScoreRank_py(pkid);
            run_OnlineDataDeal_py(pkid);
            log.info("runPeapy end pkid="+pkid);
		} catch (Exception e) {
			log.error("runPeapy",e);
		}
	}

	//
	/*
	 * 【顺序：1、OnlineDataDeal.py;2、OnlineOptimize.py;3、OnlineFeeScore.py;4、OnlineScoreRank.py;5、OnlineFrequency.py】
	 *
	 */
//
	///【执行数据处理文件】
	public static void run_OnlineDataDeal_py(String pkid){
//		String pkid="63765";
		PythonTool.runPythonFile(pyPath+"OnlineDataDeal.py",pkid);
//		PythonTool.runPythonFile("OnlineDataDeal.pyc",pkid);
	}
	///【执行用户电价优化文件】
	public static void run_OnlineOptimize_py(String pkid){
//		String pkid="63765";
		PythonTool.runPythonFile(pyPath+"OnlineOptimize.py",pkid);
//		PythonTool.runPythonFile("OnlineOptimize.pyc",pkid);
	}
	///【执行电费得分文件】
	public static void run_OnlineFeescore_py(String pkid){
//		String pkid="63765";
		PythonTool.runPythonFile(pyPath+"OnlineFeescore.py",pkid);
//		PythonTool.runPythonFile("OnlineFeescore.pyc",pkid);
	}
	///【执行得分排名文件】
	public static void run_OnlineScoreRank_py(String pkid){
//		String pkid="63765";
		PythonTool.runPythonFile(pyPath+"OnlineScoreRank.py",pkid);
//		PythonTool.runPythonFile("OnlineScoreRank.pyc",pkid);
	}
	///【执行得分频数文件】
	private static void run_OnlineFrequency_py(String pkid){
//		String pkid="63765";
		PythonTool.runPythonFile(pyPath+"OnlineFrequency.py",pkid);
//		PythonTool.runPythonFile("OnlineFrequency.pyc",pkid);
	}
	//
	public static void main(String[] args) {
		run_OnlineDataDeal_py("63765");
		run_OnlineOptimize_py("63765");
		run_OnlineFeescore_py("63765");
		run_OnlineScoreRank_py("63765");
		run_OnlineFrequency_py("63765");
	}
//
}
